<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use DB;
use Session;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
	
	
	
	
	
	/*
	* 	读取全部日志 
	*/
	public function read_All_Log()
	{
		// 查询全部数据
		$log_info = DB::table('log as l')
					-> select('l.*','a.name')
					-> leftJoin('admin as a','a.id','=','l.admin_id')
					-> orderBy('l.log_at','desc')
					// 暂取100条
					-> take(100)
					-> get();
		// 返回
		return $log_info;
	}
	
	
	/*
	* 	操作提示 
	* 	参数：  $data    携带数据
				$info 	 提示信息
	* 		  	$code 	 状态码
	*/
	public function ajAxReturn( $info='',$data=array(),$code='' )
	{
		$return = array(
			'show_info' => $info,
			'data' => $data,
			'code' => $code
		);
		exit( json_encode( $return ) );
	}
	
	
	/*
	* 	查询后台管理员资料
	* 	参数：$admin_id 
	*/
	public function getAdminName( $admin_id='' )
	{
		// 查询
		$admin_info = DB::table('admin')
						-> where( 'id','=',$admin_id )
						-> first();
		// 返回
		return $admin_info;
	}
	
}
